﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Invoice.Helper
{
    public static class KNSDateTimeHelper
    {
        public static DateTime GetDate(string sdate)
        {
            string[] s = sdate.Split(new char[] { '/' });
            DateTime d = DateTime.Now;
            try
            {
                switch (sdate)
                {
                    case "dd/mm/yyyy":
                        {
                            d = Convert.ToDateTime(s[0] + "/" + s[1] + "/" + s[2]);
                        } break;
                    case "dd/yyyy/mm":
                        {
                            d = Convert.ToDateTime(s[0] + "/" + s[2] + "/" + s[1]);
                        } break;
                    case "mm/dd/yyyy":
                        {
                            d = Convert.ToDateTime(s[1] + "/" + s[0] + "/" + s[2]);
                        } break;
                    case "mm/yyyy/dd":
                        {
                            d = Convert.ToDateTime(s[1] + "/" + s[2] + "/" + s[0]);
                        } break;
                    case "yyyy/dd/mm":
                        {
                            d = Convert.ToDateTime(s[2] + "/" + s[0] + "/" + s[1]);
                        } break;
                    case "yyyy/mm/dd":
                        {
                            d = Convert.ToDateTime(s[2] + "/" + s[1] + "/" + s[0]);
                        } break;
                }
            }
            catch { }
            return d;
        }
    }
}
